package cz.cuni.mff.ufal.volk;

import cz.cuni.mff.ufal.httpserver.protocol.HttpRequest;
import cz.cuni.mff.ufal.httpserver.protocol.HttpResponse;

/**
 * Common HTTP listener that can process bunny's requests.
 *
 * <p>All methods must be thread-safe.</p>
 *
 * @author Bartłomiej Etenkowski
 */
public interface NabaztagHttpListener {

  /**
   * Called after the bunny has requested the bootcode.
   * @param  request  the request
   * @param  response the response
   * @throws MalformedRequestException if the request is malformed
   */
  void boot(HttpRequest request, HttpResponse response) throws MalformedRequestException;

  /**
   * Called after the bunny has requested the IP addresses of the servers.
   * @param  request  the request
   * @param  response the response
   * @throws MalformedRequestException if the request is malformed
   */
  void locate(HttpRequest request, HttpResponse response) throws MalformedRequestException;

  /**
   * Called after the bunny has requested the <tt>/vl/p4.jsp</tt> resource.
   * @param  request  the request
   * @param  response the response
   * @throws MalformedRequestException if the request is malformed
   */
  void ping(HttpRequest request, HttpResponse response) throws MalformedRequestException;

  /**
   * Called after the bunny has sent a recorded sound.
   * @param  request  the request
   * @param  response the response
   * @throws MalformedRequestException if the request is malformed
   */
  void record(HttpRequest request, HttpResponse response) throws MalformedRequestException;

  /**
   * Called after the bunny has detected an RFID chip.
   * @param request  the request
   * @param response the response
   */
  void rfid(HttpRequest request, HttpResponse response);

  /**
   * Called after the bunny has requested a local resource.
   * @param  request  the request
   * @param  response the response
   * @param  resource the requested resource
   */
  void localResource(HttpRequest request, HttpResponse response, String resource);

}
